package cn.lyjuan.android.demofive.ui.component.recyclerview;

import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import cn.lyjuan.android.demofive.R;
import cn.lyjuan.android.mylibrary.view.holder.RecyclerViewHolder;

/**
 * Created by chad on 06/11/2017.
 */

public class RecyclerListAdapter extends RecyclerView.Adapter<RecyclerViewHolder>
{
    private List<String> list;

    private int resource;

    public RecyclerListAdapter(List<String> list, int resource)
    {
        this.list = list;
        this.resource = resource;
    }



    @Override
    public RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        return RecyclerViewHolder.inflater(parent, resource);
    }

    @Override
    public void onBindViewHolder(RecyclerViewHolder holder, int position)
    {
        ((TextView) holder.get(R.id.recycler_list_item)).setText(list.get(position));
    }

    @Override
    public int getItemCount()
    {
        return list.size();
    }
}
